"""
Copyright (c) 2022 Huawei Technologies Co.,Ltd.

openGauss is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:

          http://license.coscl.org.cn/MulanPSL2

THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
"""
"""
Case Type   :
Case Name   : 
Create At   : 
Owner       : 
Description :
    1、
    2、
Expect      :

    1、
    2、
History     :
"""
import unittest
import warnings

from openGaussMigrate.common.base import Base
from openGaussMigrate.common.com_log import ComLog
from openGaussMigrate.common.com_node import Macro
from openGaussMigrate.common.com_unit_action import ComUnitAction


class ExampleCase001(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        warnings.simplefilter("ignore", ResourceWarning)
        web = Macro('WEB_INFO')
        cls.driver = ComUnitAction(web.info['driver_path'], web.info['url'])
        cls.driver.open()
        cls.driver.login(web.info['user'], web.info['passwd'])
        cls.log = ComLog(cls.__name__)
        cls.log.info('i am setUpClass')

    def setUp(self):
        self.log.info('i am setup')

    def test_case1(self):
        """测试用例1"""
        self.log.info('i am test_case1')

    def test_case2(self):
        """测试用例2"""
        self.log.info('i am test_case2')

    # 装饰器，用例失败时重新执行，重新执行次数max_n
    @Base.retry(max_n=1)
    # 装饰器，当你用例错误了，那么会自动调用save_img截图方法，存到指定目录下
    @Base.save_img_when_err(cls_name='ExampleCase001')
    def test_case3(self):
        """测试用例3"""
        self.log.info('i am test_case3')
        self.driver.logout()

    def tearDown(self):
        self.log.info('i am teardown')

    @classmethod
    def tearDownClass(cls):
        cls.log.info('i am tearDownClass')
        cls.driver.close()


if __name__ == "__main__":
    unittest.main()
